<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
${error}
</body>
<script src="/js/jquery-1.8.2.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>
    wx.config({
        debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId: '${appId}', // 必填，公众号的唯一标识
        timestamp: '${timestamp}', // 必填，生成签名的时间戳
        nonceStr: '${nonceStr}', // 必填，生成签名的随机串
        signature: '${signature}',// 必填，签名，见附录1
        jsApiList: ['startRecord', 'stopRecord', 'translateVoice', 'uploadVoice', 'playVoice', 'onMenuShareAppMessage', 'onMenuShareTimeline', 'onMenuShareQQ', 'translateVoice', 'getNetworkType', 'scanQRCode', 'onMenuShareWeibo', 'onMenuShareQZone','chooseCard'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
    });
  wx.ready(function(){

      wx.addCard({
          cardList: [
              {
                  cardId: '${cardId}',
                  cardExt: '{"code": "", "openid": "", "timestamp": ${timestamp}, "signature":${cardSign}}'
              }/*,
              {
                  cardId: 'pDF3iY9tv9zCGCj4jTXFOo1DxHdo',
                  cardExt: '{"code": "", "openid": "", "timestamp": "1418301401", "signature":"f54dae85e7807cc9525ccc127b4796e021f05b33"}'
              }*/
          ],
          success: function (res) {
              alert('已添加卡券：' + JSON.stringify(res));
          }
      });
      wx.chooseCard({
          shopId: '', // 门店Id
          cardType: '${cardType}', // 卡券类型
          cardId: '${cardId}', // 卡券Id
          timestamp: '${timestamp}', // 卡券签名时间戳
          nonceStr: '${nonceStr}', // 卡券签名随机串
          signType: 'SHA1', // 签名方式，默认'SHA1'
          cardSign: '${cardSign}', // 卡券签名
          success: function (res) {
              var cardList= res.cardList; // 用户选中的卡券列表信息
              alert(JSON.stringify(res));
          }
      });
  });
    document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
        /*发送给好友*/
        WeixinJSBridge.on('menu:share:appmessage', function (argv) {
            WeixinJSBridge.invoke('sendAppMessage', {
                "img_url": "http://data.fanrenqiji.com/upload/avtar0.jpg",
                "link": "u15276z866.iask.in/test/abc",
                "desc": "请叫我中路杀神",
                "title": "发送好友测试"
            }, function (res) {
                if (res.err_msg == 'send_app_msg:ok' || res.err_msg == 'send_app_msg:confirm') {
                    //转发成功
                    alert("转发成功");
                }
                ;
                alert(JSON.stringify(res));
            });
        });

        //分享到朋友圈
        WeixinJSBridge.on('menu:share:timeline', function (argv) {
            WeixinJSBridge.invoke('shareTimeline', {
                "img_url": "http://data.fanrenqiji.com/upload/avtar0.jpg",
                "link": "u15276z866.iask.in/test/abc",
                "desc": "请叫我中路杀神",
                "title": "发送朋友圈测试"
            }, function (res) {
                alert(JSON.stringify(res));
            });
        });

        //分享到微博
        /*     WeixinJSBridge.on('menu:share:weibo', function(argv){
                 WeixinJSBridge.invoke('shareWeibo',{
                     "content":"中路杀神",
                      "url":"www.baidu.com"
                 }, function(res) {
                     alert(JSON.stringify(res));
                 });
             });*/
        //分享到qq空间
        /*   WeixinJSBridge.on('menu:share:qzone', function (argv) {
               WeixinJSBridge.invoke('shareQzone',{
                   "img_url":"http://data.fanrenqiji.com/upload/avtar0.jpg",
                   "link":"u15276z866.iask.in/test/abc",
                   "desc":"请叫我中路杀神",
                   "title":"发送qq空间"
               }, function (res) {
                   alert(JSON.stringify(res));
               });
           });*/
        //分享到qq
        /*      WeixinJSBridge.on('menu:share:qq', function (argv) {
                  WeixinJSBridge.invoke('shareQq',{
                      "img_url":"http://data.fanrenqiji.com/upload/avtar0.jpg",
                      "link":"u15276z866.iask.in/test/abc",
                      "desc":"请叫我中路杀神",
                      "title":"发送到qq"
                  }, function (res) {
                      alert(JSON.stringify(res));
                  });
              });*/
    }, false);
</script>
</html>